package cn.gene.timeyan.common.exception.handler;

import cn.gene.timeyan.common.exception.TimeyanServiceException;
import cn.gene.timeyan.common.restful.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器*
 *
 * @author LWG
 * @date 2022/7/21 19:43
 * @since 1.0.0@gene.cn
 */
@RestControllerAdvice
@Slf4j
public class GlobalControllerExceptionHandler {
    @ExceptionHandler(TimeyanServiceException.class)
    public JsonResult<Void> handleServiceException(TimeyanServiceException ex) {
        return JsonResult.failed(ex.getResponseCode(), ex.getMessage());
    }
}
